import Vue from 'vue'
import Router from 'vue-router'
// account
const Account = resolve => require(['views/account'], resolve)
const Register = resolve => require(['views/account/register'], resolve)
const Login = resolve => require(['views/account/login'], resolve)
const PhoneLogin = resolve => require(['views/account/login/phonelogin'], resolve)
const QrCodeLogin = resolve => require(['views/account/login/qrCodeLogin'], resolve)
const SocialLogin = resolve => require(['views/account/login/socialLogin'], resolve)
// appMain
const Layout = resolve => require(['views/layout'], resolve)
// dashboard 首页
const Dashboard = resolve => require(['views/dashboard'], resolve)
// find 发现页
const Find = resolve => require(['views/find'], resolve)
// question 问题页
const Question = resolve => require(['views/question'], resolve)
// videoDetails 视频详情页
const VideoDetails = resolve => require(['views/videoDetails'], resolve)
// user 用户中心
const User = resolve => require(['views/user'], resolve)
// userInfo 用户个人信息页面
const UserInfo = resolve => require(['views/user/userInfo'], resolve)

Vue.use(Router)
const socialRouter = [
  {
    path: '',
    name: '/',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {path: '/dashboard', name: 'dashboard', component: Dashboard, meta: {title: 'dashboard'}},
      {path: '/find', name: 'find', component: Find, meta: {title: 'find'}},
      {path: '/question', name: 'question', component: Question, meta: {title: 'question'}},
      {path: '/videodetails', name: 'videodetails', component: VideoDetails, meta: {title: 'videodetails'}},
      {path: '/user', name: 'user', component: User},
      {path: '/userinfo', name: 'userinfo', component: UserInfo}
    ]
  },
  {
    path: '/account',
    name: 'account',
    component: Account,
    redirect: '/account/login',
    children: [
      {path: 'login', name: 'login', component: Login, hidden: true},
      {path: 'register', name: 'register', component: Register, hidden: true},
      {path: 'phonelogin', name: 'phonelogin', component: PhoneLogin, hidden: true},
      {path: 'qrcodelogin', name: 'qrcodelogin', component: QrCodeLogin, hidden: true},
      {path: 'sociallogin', name: 'sociallogin', component: SocialLogin, hidden: true}
    ]
  }
]
const router = new Router({
  routes: socialRouter
})

export default router
